/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author George
 */
@Entity
@Table(name = "COMPROBANTE", catalog = "BDACCELCOM", schema = "dbo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Comprobante.findAll", query = "SELECT c FROM Comprobante c"),
    @NamedQuery(name = "Comprobante.findByNroVenta", query = "SELECT c FROM Comprobante c WHERE c.nroVenta = :nroVenta"),
    @NamedQuery(name = "Comprobante.findByTipoComprobante", query = "SELECT c FROM Comprobante c WHERE c.tipoComprobante = :tipoComprobante"),
    @NamedQuery(name = "Comprobante.findByFecha", query = "SELECT c FROM Comprobante c WHERE c.fecha = :fecha")})
public class Comprobante implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "NroVenta")
    private Integer nroVenta;
    @Basic(optional = false)
    @Column(name = "TipoComprobante")
    private int tipoComprobante;
    @Column(name = "Fecha")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecha;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "nerVenta")
    private List<Factura> facturaList;
    @JoinColumn(name = "NroVenta", referencedColumnName = "NroVenta", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Venta venta;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "nroVenta")
    private List<Boleta> boletaList;

    public Comprobante() {
    }

    public Comprobante(Integer nroVenta) {
        this.nroVenta = nroVenta;
    }

    public Comprobante(Integer nroVenta, int tipoComprobante) {
        this.nroVenta = nroVenta;
        this.tipoComprobante = tipoComprobante;
    }

    public Integer getNroVenta() {
        return nroVenta;
    }

    public void setNroVenta(Integer nroVenta) {
        this.nroVenta = nroVenta;
    }

    public int getTipoComprobante() {
        return tipoComprobante;
    }

    public void setTipoComprobante(int tipoComprobante) {
        this.tipoComprobante = tipoComprobante;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    @XmlTransient
    public List<Factura> getFacturaList() {
        return facturaList;
    }

    public void setFacturaList(List<Factura> facturaList) {
        this.facturaList = facturaList;
    }

    public Venta getVenta() {
        return venta;
    }

    public void setVenta(Venta venta) {
        this.venta = venta;
    }

    @XmlTransient
    public List<Boleta> getBoletaList() {
        return boletaList;
    }

    public void setBoletaList(List<Boleta> boletaList) {
        this.boletaList = boletaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (nroVenta != null ? nroVenta.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Comprobante)) {
            return false;
        }
        Comprobante other = (Comprobante) object;
        if ((this.nroVenta == null && other.nroVenta != null) || (this.nroVenta != null && !this.nroVenta.equals(other.nroVenta))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.Comprobante[ nroVenta=" + nroVenta + " ]";
    }
    
}
